//
//  RecordTableViewCell.m
//  Run
//
//  Created by sxz on 16/4/7.
//  Copyright © 2016年 BetaTheta. All rights reserved.
//

#import "RecordTableViewCell.h"

@implementation RecordTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.distance = [[UILabel alloc] initWithFrame:CGRectZero];
        self.time = [[UILabel alloc] initWithFrame:CGRectZero];
        
        self.timeImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.distanceImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.flagImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        
        [self.contentView addSubview:self.distance];
        [self.contentView addSubview:self.time];
        [self.contentView addSubview:self.timeImageView];
        [self.contentView addSubview:self.distanceImageView];
        [self.contentView addSubview:self.flagImageView];
        
    }
    return self;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    // 路程
    self.distanceImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.height / 3, self.contentView.frame.size.height / 3);
    self.distanceImageView.center = CGPointMake(self.distanceImageView.frame.size.width / 2 + 10, self.contentView.frame.size.height / 2);
    self.distanceImageView.image = [[UIImage imageNamed:@"sport"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    self.distance.frame = CGRectMake(self.distanceImageView.frame.origin.x + self.distanceImageView.frame.size.width, self.distanceImageView.frame.origin.y, self.contentView.frame.size.width * 0.35, self.distanceImageView.frame.size.height);
//    self.distance.text = @"--KM";
    self.distance.textAlignment = NSTextAlignmentLeft;
    self.distance.font = [UIFont boldSystemFontOfSize:16];
    
    // 时间
    self.timeImageView.frame = CGRectMake(self.distance.frame.origin.x + self.distance.frame.size.width, self.distance.frame.origin.y, self.distanceImageView.frame.size.width, self.distanceImageView.frame.size.height);
    self.timeImageView.image = [[UIImage imageNamed:@"time"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    self.time.frame = CGRectMake(self.timeImageView.frame.origin.x + self.timeImageView.frame.size.width, self.timeImageView.frame.origin.y, self.distance.frame.size.width, self.timeImageView.frame.size.height);
//    self.time.text = @"00'00\"";
    self.time.textAlignment = NSTextAlignmentLeft;
    self.time.font = [UIFont boldSystemFontOfSize:16];
    
    
    // 进入
    self.flagImageView.frame = CGRectMake(self.time.frame.size.width + self.time.frame.origin.x, self.time.frame.size.height, self.contentView.frame.size.width * 0.1, self.timeImageView.frame.size.height);
    self.flagImageView.image = [[UIImage imageNamed:@"enter"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
